import request from "@/utils/request";

//类型1-1:attr列表单个值的类型
export interface oneAttrValue {
  id: number;
  valueName: string;
  attrId: number;
}
//类型1-2:attr列表类型
export type AttrValueList = oneAttrValue[];
//类型1-3:获取平台属性列表返回信息类型
export interface attrInfo {
  id: number;
  attrName: string;
  categoryId: number;//所属分类ID
  categoryLevel: number;//分类等级
  attrValueList: AttrValueList;//平台属性值列表
}
//请求1:获取平台属性列表
export const reqAttrInfoList = (
  category1Id: number,
  category2Id: number,
  category3Id: number
) => {
  return request.get<any,attrInfo[]>(
    `/product/attrInfoList/${category1Id}/${category2Id}/${category3Id}`
  );
};


//类型2-1 平台属性请求参类型
export type ReqSaveAttrValue = Pick<oneAttrValue, "valueName"> & {
  id?: number;
  attrId?: number;
} & {
  isEdit?: boolean;
};
export type typeSaveAttrRef = Omit<attrInfo,"id"|"attrValueList">& {
  id?: number;
} & {
  attrValueList: ReqSaveAttrValue[];
};
//请求2:保存平台属性
export const reqSaveAttrInfo = (data:typeSaveAttrRef)=>{
  return request.post<any,any>(`/product/saveAttrInfo`,data)
}





//请求3:删除指定平台属性
export const reqDeleteAttr = (id:string)=>{
  return request.delete<any,any>(`/product/deleteAttr/${id}`)
}